<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 用户输入一个数值，去数组中寻找该数的下标，有则打印该数第一次出现的下标，没有则打印-1

* 例如: [88,20,10,100,50]  打印 2
* 例如: [88,20,30,100,50]  打印-1 -->
<script>
    let num =[88,20,10,100,50]
    let i=-1
    for (let index = 0; index < num.length; index++) {
       if(num[index]==20){
         i=index
        break
       }
           
    }
    console.log(i);
</script>
</body>
</html>